function ajaxDoc(cid){
    
    xmlhttp = new XMLHttpRequest();
    
    xmlhttp.onreadystatechange = function(){
        if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
            var text = xmlhttp.responseText;
            categoryJSON(text);
        }
    }
    
    xmlhttp.open("POST", "./background/room_add_category_ajax_do.jsp", true);
    xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    var send_text = "cid=" + cid;
    xmlhttp.send(send_text);

}

function categoryJSON(text){
    var cateObj = JSON.parse(text);
    
    var roomAddObj = getRoomAddObj();
    // alert(roomAddObj.intro.value + ", " + roomAddObj.price.value + ", " + roomAddObj.area.value);
    roomAddObj.intro.value = cateObj.intro;
    roomAddObj.price.value = cateObj.price + "$/day";
    roomAddObj.area.value = cateObj.area_min + " ~ " + cateObj.area_max + "mm";
    roomAddObj.singleBed.style.display = cateObj.bed == 1 ? "inline" : "none";
    roomAddObj.doubleBed.style.display = cateObj.bed == 2 ? "inline" : "none";
    roomAddObj.wifi.style.display = cateObj.wifi == "true" ? "inline" : "none";
    roomAddObj.bathroom.style.display = cateObj.bathroom == "true" ? "inline" : "none";
}

function getRoomAddObj(){
    var introElem = document.getElementById("room_add_category_intro");
    var priceElem = document.getElementById("room_add_category_price");
    var area = document.getElementById("room_add_category_area");
    var singleBed = document.getElementById("room_add_category_single_bed");
    var doubleBed = document.getElementById("room_add_category_double_bed");
    var wifi = document.getElementById("room_add_category_wifi");
    var bathroom = document.getElementById("room_add_category_bathroom");
    
    var obj = {
        intro : introElem,
        price : priceElem,
        area  : area,
        singleBed : singleBed,
        doubleBed : doubleBed,
        wifi  : wifi,
        bathroom  : bathroom
    }
    
    return obj;
}